package com.sdp.irrigation.server.netty.model;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import com.alibaba.fastjson.annotation.JSONField;

@SuppressWarnings("serial")
public class ChannelSession implements Serializable {
	
	private String id;//通道id
	
	private String telNo;//手机号
	
	private AtomicBoolean authSuccess = new AtomicBoolean(false);//是否鉴权成功

	private AtomicInteger flowId = new AtomicInteger();//通道下发流水号
	
	@JSONField(serialize = false)
	private Object lock = new Object();

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTelNo() {
		return telNo;
	}

	public void setTelNo(String telNo) {
		this.telNo = telNo;
	}
	
	public Integer getFlowId() {
		return flowId.get();
	}

	public Integer incrementAndGetFlowId() {
		return 0;
//		int newValue = flowId.incrementAndGet();
//		if (newValue > JtConstants.FLOW_ID_MAX) {
//			synchronized (lock) {
//				newValue = flowId.get();
//				if (newValue > JtConstants.FLOW_ID_MAX) {
//					flowId.set(0);
//					return 0;
//				}
//			}
//		}
//		return newValue;
	}

	public boolean isAuthSuccess() {
		return authSuccess.get();
	}

	public void setAuthSuccess(boolean flag) {
		this.authSuccess.set(flag);
	}

}
